package domain;

import java.util.HashMap;
import java.util.Map;

public class Score {
	
	
	private Map<String,Double> values;
	private String[] keys;
	
	public Score(String values) {
		createMap(values);
	}
	
	public Double getScore(String key) {		
		return values.get(key);
	}
	
	public void setScore(String key,Double score) {		
		this.values.put(key, score);
	}
	
	private void createMap(String values) {
		keys = values.split(",");
		this.values = new HashMap<String, Double>();
		
		for (String key: keys) {
			this.values.put(key, 0.0);
		}
	}
	
	public String toString() {
		
		StringBuilder sb = new StringBuilder();
		
		sb.append("{");
		
		for (String key: keys) {
			sb.append(key + ":");
			sb.append(values.get(key) + ",");
		}
		
		sb.deleteCharAt(sb.length() - 1);
		sb.append("}");
		
		return sb.toString();
	}
	
	
	public String[] getKeys() {		
		return keys;
	}
}
